1. Field
The disclosed embodiments relate to the processing of commands by devices in a computer system. More specifically, the disclosed embodiments relate to techniques for managing the allocation of a set of tags to a set of devices connected to a host, in which the tags are used to queue commands from the host to the devices and track the status of the queued commands.
2. Related Art
A modern computer system typically includes a motherboard containing a processor and memory, along with a set of devices connected to the motherboard through a number of interfaces. For example, a Serial Advanced Technology Attachment (SATA) interface may facilitate data transfer between one or more storage devices (e.g., hard disk drives, optical drives, solid-state drives, hybrid hard drives, etc.) and the motherboard. A SATA host bus adapter may provide the SATA interface, while a SATA port multiplier may allow multiple storage devices to be connected to the motherboard via the host bus adapter.
To improve the efficiency of communication between the motherboard and a device, an interface may enable the queuing of commands from the motherboard to the device. For example, a SATA interface may provide a Native Command Queuing (NCQ) mechanism that allows a processor to issue queued commands to a storage device. The queued commands may then be reordered by the storage device prior to execution to reduce latency (e.g., seek latency, rotational latency, etc.) associated with executing the queued commands.
In addition, the interface may use a set of tags to identify and track the status of queued commands in a device. For example, a SATA host bus adapter may support up to 32 numeric tags for queued commands in a SATA device. A device driver for the SATA device may issue a number of queued commands to the device, with each queued command containing a unique tag value (e.g., from 0 to 31) for the command. The device driver may also set a bit corresponding to the tag value in a 32-bit status register to indicate that the queued command is outstanding. After one or more queued commands have been completed, the device may provide a status return for the completed command(s) by clearing the bits corresponding to the tag value(s) of the completed command(s) in the status register.
However, queued commands may be difficult to identify and/or track if multiple devices are connected to the same interface. For example, each storage device connected to a SATA interface may support 32 tags for queued commands on the storage device, while a SATA host bus adapter may support 32 tags for all queued commands issued on the SATA interface. As a result, accurate identification of queued commands may be precluded if the same tag values are used to identify queued commands by multiple storage devices connected to the SATA interface (e.g., via a port multiplier).
Hence, what is needed is a mechanism for facilitating the identification and tracking of queued commands across multiple devices connected to an interface.